﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;

namespace CourseSystem.Core.Entities
{
    [Table(Name = "ExaminationSummary")]
    public class ExaminationSummaryInfo : IDetach
    {
        public ExaminationSummaryInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private int _uid = 0;
        private int _eid = 0;
        private int _score = 0;
        private string _comment = "";
        private bool _iscommit = false;
        private bool _isExcellent = false;
        private bool _isScoring = false;


        private EntityRef<ExaminationInfo> _examinationInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_examinationInfo", ThisKey = "Eid", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public ExaminationInfo ExaminationInfo
        {
            get { return _examinationInfo.Entity; }
            set { _examinationInfo.Entity = value; }
        }

        private EntityRef<StudentInfo> _studentInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_studentInfo", ThisKey = "Uid", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public StudentInfo StudentInfo
        {
            get { return _studentInfo.Entity; }
            set { _studentInfo.Entity = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Uid
        {
            set { _uid = value; }
            get { return _uid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Eid
        {
            set { _eid = value; }
            get { return _eid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Score
        {
            set { _score = value; }
            get { return _score; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public string Comment
        {
            set { _comment = value; }
            get { return _comment; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public bool IsCommit
        {
            set { _iscommit = value; }
            get { return _iscommit; }
        }

        [Column]
        public bool IsExcellent
        {
            set { _isExcellent = value; }
            get { return _isExcellent; }
        }

        [Column]
        public bool IsScoring
        {
            set { _isScoring = value; }
            get { return _isScoring; }
        }

        #endregion Model

        public void Detach()
        {
            _examinationInfo = default(EntityRef<ExaminationInfo>);
            _studentInfo = default(EntityRef<StudentInfo>);
        }
    }
}
